﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;

namespace MikroObject
{
    public class Schema
    {
        private bool Exists(SqlTransaction trn)
        {
            return Convert.ToBoolean(Data.Get.ExecScaler("select count(*) from INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME=N'FASTREST_AKTARILANLAR'", trn));
        }
        public void CreateTable()
        {
            SqlTransaction trn = Data.Get.OpenSession();
            if (!this.Exists(trn))
            {
                Data.Get.ExecQuery("CREATE TABLE FASTREST_AKTARILANLAR(id int IDENTITY NOT NULL PRIMARY KEY,evrak_tip tinyint NOT NULL,fastrest_id int NOT NULL,mikro_shar_id int NOT NULL,mikro_char_id int NULL,mikro_evrak_seri nvarchar(5) NOT NULL,mikro_evrak_sira int NOT NULL)", trn);
                Data.Get.ExecQuery("CREATE  INDEX FASTREST_AKTARILANLAR_01 ON FASTREST_AKTARILANLAR (fastrest_id,evrak_tip)", trn);
                trn.Commit();
            }
        }
    }
}
